
clear all
set more off

**** GLOBALS *****;
global 	InputFile ${dat}\HSV_repdata.dta
global 	OutputDir ${res}
global straps  500
*********************;


use ${InputFile} , clear



//levels of pre and postgov inc
gen pregovinc = max(redpregovinc - tot_deduction + 0.5*fica,0)
gen dispinc = max(reddispinc - tot_deduction + 0.5*fica + hwdpvpengain1,0)

//logs of pre and postgov inc
replace lpregovinc = log(redpregovinc - tot_deduction + 0.5*fica)
replace ldispinc = log(reddispinc - tot_deduction + 0.5*fica + hwdpvpengain1)


reg ldispinc lpregovinc
keep if e(sample)

poisson dispinc lpregovinc

sca lamb=exp(_b[_cons])
sca tau=1-_b[lpregovinc] 


sum pregovinc
sca suminc=r(sum)

gen mrate=(1-lamb*(1-tau)*pregovinc^(-tau))
gen iwmrate=(pregovinc/suminc)*mrate

sum iwmrate, d
di r(sum)








